package licode.unisop.types.util;

/**
 * 管理ID生成
 *
 * @author WR
 * @since 2016/7/9 16:15
 */
public class IdGenUtil {
    private static final int ID_SIZE = 20;

    public static String buildLoginLogId() {
        return getInnerId("LL", ID_SIZE);
    }

    public static String buildAuditLogId() {
        return getInnerId("AD", ID_SIZE);
    }

    public static String buildCallApiLogId() {
        return getInnerId("CA", ID_SIZE);
    }

    public static String buildUserId() {
        return getInnerId("UR", ID_SIZE);
    }

    public static String buildUserGroupAssignId() {
        return getInnerId("GA", ID_SIZE);
    }

    public static String buildUserGroupId() {
        return getInnerId("UP", ID_SIZE);
    }

    public static String buildPlatformId() {
        return getInnerId("PF", ID_SIZE);
    }

    public static String buildPlatformUserId() {
        return getInnerId("PU", ID_SIZE);
    }

    public static String buildClientPermitId() {
        return getInnerId("CP");
    }

    public static String buildClientId() {
        return getInnerId("CL", ID_SIZE);
    }

    public static String buildAccountId() {
        return getInnerId("AC");
    }

    public static String buildAccountNo() {
        return getInnerId("AN");
    }

    public static String buildAuthInfoId() {
        return getInnerId("AI");
    }

    public static String buildMenuId() {
        return getInnerId("MU", ID_SIZE);
    }

    public static String buildRoleId() {
        return getInnerId("RL", ID_SIZE);
    }
    public static String buildRelationId() {
        return getInnerId("AR", ID_SIZE);
    }
    public static String buildUrlInfoId() {
        return getInnerId("UL", ID_SIZE);
    }

    public static String buildPermitInfoId() {
        return getInnerId("MM");
    }

    public static String buildPlatformToken() {
        return getInnerId("PT");
    }

    public static String buildPlatformInnerToken() {
        return getInnerId("PI");
    }

    public static String buildRoleMenu() {
        return getInnerId("RM");
    }

    public static String buildGrantPlatformId() {
        return getInnerId("GP");
    }

    public static String buildRealmId() {
        return getInnerId("RI");
    }

    private static String getInnerId(String prefix) {
        return getInnerId(prefix, ID_SIZE);
    }

    public static String buildSimpleId() {
        return java.util.UUID.randomUUID().toString();
    }

    private static String getInnerId(String prefix, int size) {
        return prefix + java.util.UUID.randomUUID().toString()
                .trim().replaceAll("-", "").substring(0, size).toUpperCase();
    }
}
